<?php

namespace app\store\controller\user;

use app\store\controller\Controller;
use app\store\model\User as UserModel;

/**
 * 记录
 * Class Recharge
 * @package app\store\controller\user
 */
class Relationship extends Controller
{
    /**
     * 记录
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function superior()
    {
        $model = new UserModel;
        $param = $this->request->param();
        if(isset($param['nickName'])){
            !empty($params['nickName']) && $model->where('nickName,phone', 'like', "%{$params['nickName']}%");
        }

        $list = $model->where('user_id',$param['user_id'])
            ->order(['create_time' => 'desc'])
            ->paginate(15, false, [
                'query' => request()->request()
            ]);
        foreach ($list as &$value){
            $value['grade_name'] = model('user_grade')->where('grade_id',$value['grade_id'])->value('name');
        }
        return $this->fetch('order', [
            // 充值记录列表
            'list' => $list,
            // 属性集
           // 'attributes' => $model::getAttributes(),
        ]);
    }

    public function subordinate()
    {
        $model = new UserModel;
        $param = $this->request->param();
        if(isset($param['nickName'])){
            !empty($param['nickName']) && $model->where('nickName|phone', 'like', "%{$param['nickName']}%");
        }
        $list = $model->where('referee_id',$param['user_id'])
            ->order(['create_time' => 'desc'])
            ->paginate(15, false, [
                'query' => request()->request()
            ]);
        foreach ($list as &$value){
            $value['grade_name'] = model('user_grade')->where('grade_id',$value['grade_id'])->value('name');
        }
        return $this->fetch('orders', [
            // 充值记录列表
            'list' => $list,
            // 属性集
            // 'attributes' => $model::getAttributes(),
        ]);
    }

}